package student;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.Scanner;

public class StudentClient {
    public static void main(String[] args) {
        try {
            Socket socket = new Socket("localhost", 9901);
            Scanner scanner = new Scanner(System.in);
            Student student = new Student();
            String stuNo = null;
            String name = null;
            String phone = null;
            String email = null;

            System.out.println("请输入学号：");
            stuNo = scanner.nextLine();
            student.setStuNo(stuNo);

            System.out.println("请输入姓名：");
            name = scanner.nextLine();
            student.setName(name);


            System.out.println("请输入电话：");
            phone = scanner.nextLine();
            student.setPhone(phone);


            System.out.println("请输入邮件：");
            email = scanner.nextLine();
            student.setEmail(email);

            ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
            oos.writeObject(student);

            ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
            System.out.println(ois.readObject());
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
